import { Injectable } from '@angular/core';
import {
    DEBUG_INFO_ENABLED,
    EQUIPMENT_API_URL,
    ACTIVE_MQ_URL,
    GIS_SERVICE_URL,
    ITMP_HOST_NAME,
    LOGIN_API_URL,
    API_GATEWAY,
    ACTIVE_MQ_user,
    ACTIVE_MQ_Pwd,
    UPLOADBASE,
    VMSERR,
    DSS_GIS_SOE
} from 'app/app.constants';

@Injectable()
export class ConfigService {
    /**
     * 调试模式
     */
    public isDebug = DEBUG_INFO_ENABLED;

    public itmpHostName = ITMP_HOST_NAME;

    private _API_GATEWAY = API_GATEWAY;
    private UPLOADBASE = UPLOADBASE;
    private _VMSERR = VMSERR;
    private _DSS = DSS_GIS_SOE;
    // private _xxxx = XXXX;   // 统一网关后用这个
    public apiUrl = {
        incident: `${this._API_GATEWAY}/vnqnincidentmgt`, // incident_Mgt
        user: `${this._API_GATEWAY}/vnqnusermgt`, // user_Mgt,
        login: LOGIN_API_URL, // login
        alert: `${this._API_GATEWAY}/vnqnalertmgt`, // alert_Mgt
        alarm: `${this._API_GATEWAY}/vnqnalarmmgt`, // alarm_Mgt
        equipment: `${this._API_GATEWAY}/vnqnequipmgt`, // equipment_Mgt
        vnqntscmgt: `${this._API_GATEWAY}/vnqntscmgt`,
        responseplan: `${this._API_GATEWAY}/vnqnresponseplan`, // responseplan
        vms: `${this._API_GATEWAY}/vnqnvmsmgt`, // dissimination_Mgt
        report: `${this._API_GATEWAY}/vnqnreportmgt`, // report_Mgt
        log: `${this._API_GATEWAY}/vnqnoperationlog`, // log_Mgt
        enum: `${this._API_GATEWAY}/vnqnenummgt`, // enum
        zone: `${this._API_GATEWAY}/vnqnzonemgt`, // zoneid
        // enum: `http://192.168.0.93:9599`, // enum
        uploadBase64: `${this.UPLOADBASE}`, // uploadBase64
        activeMq: ACTIVE_MQ_URL,
        activeMq_user: ACTIVE_MQ_user,
        activeMq_Pwd: ACTIVE_MQ_Pwd,
        gis: GIS_SERVICE_URL,
        vmsErr: `${this._VMSERR}`
    };
    constructor() {}

    /**
     * 对象格式化拼接
     * @param {any} data [对象 eg:{a:'a',b:'b',c:1}]
     * return a=a&b=b&c=1
     */
    public formatGetUrl(data: any) {
        // this.defaultPaging(data)
        let ret = '';
        for (const i in data) {
            if (data.hasOwnProperty(i)) {
                ret = ret.length > 0 ? ret + '&' : ret;
                ret = ret + i + '=' + data[i];
            }
        }
        return ret;
    }

    /* get xxxx(): string {
		return this._xxxx;
	} */
}

/**
 * 页码
 */
/* export interface Page {
  // 条数
  size?: number;
  // 页码
  page?: number;
  // 排序字段
  sort?: string;
} */

/**
 * API
 */
/* export interface Result<T> {
  content?: T;
  errCode: number;
  msg?: string;
} */

/* export interface PageRes<T> {
  content: Array<T>;
  first: boolean;
  last: boolean;
  number: number;
  numberOfElements: number;
  size: number;
  sort: any;
  totalElements: number;
  totalPages: number;
}
 */
